package com.midian.model.common.vo;

import java.util.Enumeration;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

public class RequestVo extends HttpServletRequestWrapper {
	private Map params;

	public RequestVo(HttpServletRequest request, Map params) {
		super(request);

		this.params = params;
	}

	public Map getParameterMap() {
		return super.getParameterMap();
	}

	@Override
	public Enumeration getParameterNames() {
		return super.getParameterNames();
	}

	@Override
	public String[] getParameterValues(String name) {
		String[] values = super.getParameterValues(name);
		if (values != null) {
			for (int i = 0; i < values.length; i++) {
				if (values[i] != null && !"".equals(values[i])) {
					//System.out.println("更改前="+ values[i]);
					String str = values[i] + "";
					str = str.replaceAll("&", "&amp;");
					str = str.replaceAll("<", "&lt;");
					str = str.replaceAll(">", "&gt;");
					str = str.replaceAll("\"", "&quot;");
					values[i] = str;
					//System.out.println("更改后="+ values[i]);
				}
			}
		}
		return values;
	}

	@Override
	public String getParameter(String name) {
		String parameter = super.getParameter(name);
		if (parameter != null && !"".equals(parameter)) {
			//System.out.println("getParameter更改前="+parameter);
			String str = parameter + "";
			str = str.replaceAll("&", "&amp;");
			str = str.replaceAll("<", "&lt;");
			str = str.replaceAll(">", "&gt;");
			str = str.replaceAll("\"", "&quot;");
			parameter = str;
			//System.out.println("getParameter更改后="+parameter);
		}
		return parameter;
	}
}
